Members:Jack Li;Ian Lin;Seko Ng

Summery of Database Knowledge


Database management system is to organize and retrieve data in a faster way.

The 3 Normalization rules:


  1. There must not be repeating data anywhere in one table.---First Normal Form
  2. The attributes in the table are dependent on the entire primary key. ---Second Normal Form
  3. The primary key in the table is the only depending resource of other attributes in the table. ---Third Normal Form

Definition:

Primary Key: uniquely identifies each record in the table
Foreign Key: a field in a relational table that matches the primary key in another table ( usually the previous table).
Example For the First Normal Form ( 1NF) :

The following database table is WRONG.
- The "Supplier Name" column has duplicate data.

NF1-wrong.png


The following database table is the CORRECTED one.
Product_Id.docx_-_Microsoft_Word.jpg




Example For the Second Normal Form (2NF):


Note: The table should be already in the First Normal Form


WRONG


- Songs and Artist are the composite primary key
- Artist is not related to Time and Genre, so we have to split it into 2 or more tables
Example_for_the_Second_Normal_Form.docx[o_-_Microsoft_Word.jpg

CORRECTED

- For this time, I split it into 2 tables.
- The FIRST table is called the songs table
- The SECOND table is called the Artist table
Example_for_the_Second_Normal_Form.docx_-_Microsoft_Word.jpg

Example For the Third Normal Form (3NF)


Note: The table should be already in the First and Second Normal Form.

WRONG

- this table meets the requirements of 2NF but fail the requirements to 3NF
- Supplier Tel# is dependent on Name which is not our Primary key.
NF3_Better_Wrong.jpg

CORRECTED

NF3_Corrected_2.jpg

WRONG

3nf.jpg

EDITED

3nf1.jpg
12.jpg
ER Diagram

- it is a particular graphic that illustrates the interrelationship between entities

Two Rules
1.You CANNOT contain a null value if it is a PK
2.You CAN contain a null value if it is a non-primary key
- there are three relationships: 1. one to one 2. one to many 3. many to many

For the One-to-one relationship
- one school has one phone number, that particular phone number should only belong to one school
For the One-to-many relationship
- there is one folder collecting data, and there are many pieces of information being collected
- one school has many students
For the Many-to many relationship
- many-to-many usually cannot connect to each other, so we have to add a new table between them

Examples
- there are many suppliers of laptops,and the laptops are being sold in many shops
- one block can have many courses, one course can have many blocks

ER_Diagram.jpg
Souce